<template>
  <van-config-provider :theme-vars="themeVars">
    <div class="login_container">

      <!-- 导航栏 -->
      <van-nav-bar class="login_top" title="网易严选" @click-right="onClickRight">
        <template #left>
          <van-icon name="wap-home-o" size="32" color="#333" />
        </template>
        <template #right>
            <!-- <van-icon name="search" class="login_search" size="32" color="#333" /> -->
            <van-icon name="shopping-cart-o" size="32" color="#333" />
        </template>
      </van-nav-bar>

      <div>
        <van-icon @click="toSearch" name="search" class="login_search" size="32" color="#333" />
      </div>

      <!-- 根1 -->
      <div class="login_type">
        <!-- 下内容根组件 -->
        <div class="login_body">
          <!-- 图片 + 双登录 -->
          <div class="login_item">
            <!-- 中间logo图片 -->
            <div class="login_item_img">
              <van-image width="148" height="50" fit="contain" position="bottom"
                src="	https://yanxuan.nosdn.127.net/static-union/164793255107785e.png" />
            </div>
          </div>

          <!-- 输入验证 -->
          <div class="body_verify">
            <div class="phone_verify">
              <van-field 
              type="tel" 
              v-model="userInfoStore.loginFrom.phone"
              placeholder="请输入手机号" 
            />
            </div>

            <div class="email_verify">
              <van-cell-group inset>
                <van-field 
                center 
                clearable 
                v-model="userInfoStore.loginFrom.password"
                placeholder="请输入短信验证码"
              >
                  <template #button>
                  <button class="verification_code">发送验证码</button>
                  </template>
                </van-field>
              </van-cell-group>
            </div>
          </div>


          <!-- 遇到问题和验证登录 -->
          <div class="options">
            <span>遇到问题?</span>
            <van-button type="default" size="small" :to="{path: '/password'}">使用密码验证登录</van-button>
          </div>


          <!-- 登录 -->
            <div class="loginButton">
              <van-button class="button_phone" type="danger" size="large" @click="LoginHandle">登录</van-button>

            <!-- 霸王条款 -->
            <span class="login_select">
              <input type="checkbox" checked="true">
              <span>同意 <a href="script:;">《服务条款》</a> </span>
            </span>
          </div>

          <!-- 其他登录方式 -->
          <div class="otherOptions">
            
            <van-button type="default" size="small" to="Login">其他登录方式</van-button>
          </div>


        </div>
      </div>



    </div>
  </van-config-provider>
</template>

<script lang="ts">
  export default {
    name: 'LoginWithPhone'
  }
</script>


<script lang="ts" setup>
import { ref, reactive, createApp } from 'vue';
import { Image as VanImage, Col, Row, Button, } from 'vant'
import pinia from "@/store/index"
import { useUserInfoStore } from '@/store/userInfo'
import { useRouter } from 'vue-router'
const userInfoStore = useUserInfoStore(pinia);
const router = useRouter()

// console.log(userInfoStore.loginFrom);

const themeVars = reactive({
  // 输入框内字体
  fieldPlaceholderTextColor: '#7F7F7F',
  // button 边框颜色
  buttonDefaultBorderColor: '#fff',
});

const LoginHandle = () => {
  userInfoStore.login(userInfoStore.loginFrom.phone, userInfoStore.loginFrom.password)
  router.push({ path: '/' })
}

// 跳转购物车
const onClickRight = () => {
  router.push('/cart')
}

// 跳转到搜索页面
const toSearch = () => {
  router.push('/search')
}


</script>

<style lang="less" scoped>
/* 导航 */
.login_top {
  background: #fafafa
}

/* 根1 */
.login_type {
  height: 688px;
  display: block;

}

/* 根2 */
.login_body {
  height: 100%;
  background: #fff;
  position: relative;
}

/* 搜索向右扩展 */
.login_search {
  position: relative;
  top: -42px;
  left: 290px;
  z-index: 10;
}

/* 图片 */
.login_item_img {
  text-align: center;
  padding-top: 24px;
  margin-bottom: 40px;
}

/* 验证样式 */
.body_verify div input {
  border: none;
  border-bottom: 1px solid #d1cdcd98;
  font-size: 14px;
  width: 330px;
  height: 30px;
  margin-top: 20px;
}

/* 手机号样式 */
.phone_verify {
  padding-left: 15px;
}

/* 验证码样式 */
.email_verify {
  padding-left: -20px;
  margin-top: 10px;
  .verification_code {
    width: 82px;
    height: 26px;
    font-size: 12px;
    background-color: #fff;
    color: rgb(51, 51, 51);
    border-color: rgb(191, 191, 191);
  }
  .verification_code:active {
    background-color: rgb(191, 191, 191);
  }
}

/* 短信验证样式 */


/* .body_verify {
  margin: 0 auto;
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
} */

/* 遇到问题验证登录 */
.options {
  width: 330px;
  position: absolute;
  left: 50%;
  top: 40%;
  font-size: 14px;
  color: #524e4ec3;
  transform: translate(-50%, -50%);
}

/* 验证登录 */
.options :nth-child(2) {
  margin-left: 150px;
  color: #333333;
}

/* 按钮 */
.loginButton {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 330px;
}

/* 其他登录方式 */
.otherOptions {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translate(-50%, -50%);
  width: 100px;
  font-size: 14px;
}

/* 条款同意 */
.login_select {
  color: #333333;
  font-size: 14px;
}

--van-button-default-color {

}
</style>
